<?php

declare(strict_types=1);

namespace app\model;

use app\BaseModel;
use think\model\concern\SoftDelete;

class CartStock extends BaseModel
{
    use SoftDelete;

    protected $name = 'cart_stock';

    protected $autoWriteTimestamp = 'datetime';

    protected $json = ['snapshot_product', 'buyer_media', 'seller_media'];

    public const STATUS_PENDING = 0;
    public const STATUS_VERIFIED = 1;
    public const STATUS_REJECTED = 2;
    public const STATUS_CANCELLED = 3;

    public function buyer()
    {
        return $this->belongsTo(User::class, 'buyer_id');
    }

    public function sellerOrg()
    {
        return $this->belongsTo(Org::class, 'seller_org_id');
    }

    public function product()
    {
        return $this->belongsTo(Prod::class, 'product_id');
    }

    public function assistUser()
    {
        return $this->belongsTo(User::class, 'assist_user_id');
    }

    public function region()
    {
        return $this->belongsTo(Region::class, 'region_id');
    }
}
